<?php

require_once(FWS_DIR_LIB.'core/ModelAndView.class.php');
require_once(FWS_DIR_MODEL_DAO.'clubmodeldao.class.php');
require_once(FWS_DIR_MODEL.'clubmodel.class.php');

class clubMultiActionController {

	var $_clubmodeldao;

	function clubMultiActionController() {
		$this->_clubmodeldao = new clubModelDao();
		mysql_connect(FWS_DBDOMAIN,FWS_DBUSER,FWS_DBPASS) or exit(mysql_error());
		mysql_select_db(FWS_DBNAME) or exit(mysql_error());		
	}

	function list_action() {
		$mv = new ModelAndView();
		$mv->addToModel(0, $this->_clubmodeldao->findAllclub());
		mysql_close();		
		$mv->setView('list_club.tpl');
		return $mv;
	}

	function profile_action() {
		$mv = new ModelAndView();
		$mv->setModel($this->_clubmodeldao->queryClubById($_GET[GLOBAL_PARAM_IDCLUB]));
		mysql_close();	
		$mv->setView('profile_club.tpl');
		return $mv;
	}

	function addform_action() {
		$mv = new ModelAndView();
		mysql_close();		
		$mv->setView('club_addform.tpl');
		return $mv;
	}
	
	function updateForm_action() {
		$mv = new ModelAndView();
		$mv->addToModel(0, $this->_clubmodeldao->queryClubById($_GET[GLOBAL_PARAM_IDCLUB]));
		mysql_close();		
		$mv->setView('club_updateform.tpl');
		return $mv;
	}
	
	function update_action() {
		$mv = new ModelAndView();
		$this->_clubmodeldao->updateClub(new clubModel($_POST)); 
		//mysql_close();		
		return $this->list_action();
	}
	
	function insertForm_action() {
		$mv = new ModelAndView();
		mysql_close();		
		$mv->setView('club_insertform.tpl');
		return $mv;
	}
	
	
}

?>